<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        div.box {
            width: 300px;
            padding: 20px;
            margin: 20px;
            border: 4px dashed #ccc;
        }

        div.box > span {
            color: #999;
            font-style: italic;
        }

        div.content {
            width: 250px;
            margin: 10px 0;
            padding: 20px;
            border: 2px solid #ff6666;
        }
    </style>
    <script src="../../../jquery.min.js"></script>
</head>
<body>

<div class="box">
    <span>点击按钮获取checkbox的选中值：</span>
    <div class="content">
        <input type='checkbox' name='message' value='1'/>发送短信
        <input type='checkbox' name='message' value='2'/>发送邮件
    </div>
    <input type="button" value="提交">
</div>

<script>
    $(function () {
        $("input:button").click(function () {
            text = $("input:checkbox[name='message']:checked").map(function (index, elem) {
                return $(elem).val();
            }).get();   //这里就可以吧对象序列化为array
            let arr = [];
            $("input:checkbox[name='message']:checked").each(function (index, element) {
                arr.push($(element).val());
            });
            console.log(text);
            console.log(typeof text);
            console.log([1, 2, 3, 4, 5, 6]);
            console.log(typeof [1, 2, 3, 4, 5, 6]);

            console.log('arr',arr);
        });
    });
</script>
</body>
</html>